Conversation
Signed-off-by: Hao Wu <skyw@nvidia.com>
Signed-off-by: Hao Wu <skyw@nvidia.com>
Signed-off-by: Hao Wu <skyw@nvidia.com>
Signed-off-by: Hao Wu <skyw@nvidia.com>
Signed-off-by: Hao Wu <skyw@nvidia.com>
Signed-off-by: Hao Wu <skyw@nvidia.com>
Signed-off-by: Hao Wu <skyw@nvidia.com>
Signed-off-by: Hao Wu <skyw@nvidia.com>
Greptile SummaryThis PR improves test coverage for SOAP utilities, scalar optimizers, and precondition schedules, while fixing two bugs: (1) empty Kronecker factor eigenbasis shape corrected from Key changes:
Confidence Score: 4/5
|
| def test_all_eigenbases_met_criteria_true_eigenbasis_returns_true(self, N: int) -> None: | ||
| kronecker_factor_list = [torch.randn(N, N, device=self.device)] | ||
|
|
||
| eigenbasis_list = [torch.diag(torch.linalg.eigh(K).eigenvalues) for K in kronecker_factor_list] | ||
| self.assertTrue(soap_utils.all_eigenbases_met_criteria(kronecker_factor_list, eigenbasis_list)) |
There was a problem hiding this comment.
Wrong eigh attribute used — .eigenvalues instead of .eigenvectors
torch.linalg.eigh returns a named tuple with .eigenvalues (1-D vector λ) and .eigenvectors (N×N orthogonal matrix Q). The test wraps the 1-D eigenvalues in torch.diag(), producing a diagonal eigenvalue matrix D, and passes that to all_eigenbases_met_criteria.
However, the conjugate function (used internally) assumes its second argument is an orthogonal matrix. Passing a diagonal eigenvalue matrix instead breaks this invariant. The met_approx_eigvals_criteria check will compute a meaningless result and likely pass by chance, so the test does not validate the intended mathematical property.
Additionally, K = torch.randn(N, N) on line 200 is not symmetric; calling torch.linalg.eigh on it is undefined behaviour (PyTorch silently uses only the lower triangular part).
The test should construct a symmetric matrix and use the eigenvectors:
def test_all_eigenbases_met_criteria_true_eigenbasis_returns_true(self, N: int) -> None:
g = torch.randn(N, N, device=self.device)
K_sym = g @ g.T + torch.eye(N, device=self.device) * 1e-5 # symmetric PSD
kronecker_factor_list = [K_sym]
eigenbasis_list = [torch.linalg.eigh(K_sym).eigenvectors]
self.assertTrue(soap_utils.all_eigenbases_met_criteria(kronecker_factor_list, eigenbasis_list))There was a problem hiding this comment.
@mkhona-nvidia , should we use eigen values or eigen vectors?
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: Hao Wu <skyw@users.noreply.github.com>
Signed-off-by: Hao Wu <skyw@nvidia.com>
Signed-off-by: Hao Wu <skyw@nvidia.com>
Signed-off-by: Hao Wu <skyw@nvidia.com>
|
/ok to test b4ea359 |
Test Results 46 files + 12 96 suites +38 1m 11s ⏱️ +2s Results for commit 1215f18. ± Comparison against base commit 7056267. This pull request removes 2 and adds 40 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: Hao Wu <skyw@users.noreply.github.com>
|
/ok to test 23e4b0c |
Signed-off-by: Hao Wu <skyw@nvidia.com>
|
/ok to test 0825b7e |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: Hao Wu <skyw@users.noreply.github.com>
|
/ok to test 1215f18 |
Half done by Claude Code and I reviewed AI written code.
some tiny bugs a fixed along with it.